package br.com.kliptus.model.bean;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.maverick.bean.EntityBean;

@Entity
@Table(name = "service_order")
public class ServiceOrderJB extends EntityBean {

	private static final long serialVersionUID = 1L;
	
	private CustomerJB customer;
	private Double value;
	private List<ItemOrderJB> itemOrderList;
	
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
	public Long getId() {
		return id;
	}

	@ManyToOne
	@JoinColumn(name = "customer_id", referencedColumnName = "id")
	public CustomerJB getCustomer() {
		return customer;
	}

	public void setCustomer(CustomerJB customer) {
		this.customer = customer;
	}

	@Column(name = "value")
	public Double getValue() {
		return value;
	}

	public void setValue(Double value) {
		this.value = value;
	}

	@SuppressWarnings("deprecation")
	@OneToMany(mappedBy = "serviceOrder", fetch = FetchType.LAZY)
	@Cascade(value = {
			org.hibernate.annotations.CascadeType.ALL, 
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	public List<ItemOrderJB> getItemOrderList() {
		return itemOrderList;
	}

	public void setItemOrderList(List<ItemOrderJB> itemOrderList) {
		this.itemOrderList = itemOrderList;
	}

}